package com.flute.framework.search.strategy;

import org.apache.lucene.index.Term;
import org.apache.lucene.search.PrefixQuery;

import com.flute.tools.util.StringUtil;

public class PrefixSearchStrategy extends AbstractSearchStrategy {

	@Override
	public Object getQuery(String string) {
		return getQuery(string, null);
	}

	@Override
	public Object getQuery(String string, String sorter) {
		return getQuery(string, sorter, 1f);
	}

	@Override
	public Object getQuery(String string, String sorter, float boost) {
		if (string == null) {
			string = "";
		}
		string = StringUtil.getStandardString(string);
		string = StringUtil.chineseFJChange(string);

		PrefixQuery query = new PrefixQuery(new Term(fieldName, string));
		// LayerPayloadPrefixQuery query = new
		// LayerPayloadPrefixQuery(new Term(
		// fieldName, string));
		// TODO
		// if (!StringUtil.isNullOrEmpty(sorter)) {
		// query.setSort(sorter);
		// }
		query.setBoost(boost);

		return query;
	}
}
